<template>
  <div id="assets">
    <div class="assets-header">
      <img src="../../assets/image/assets.png" alt="">
    </div>
    <ul class="assets-list" v-if="accountList&&accountList.length>0">
      <li v-for="(item,index) in accountList" :key="index" :class="item.coinType===2?'active':''">
        <span class="assets-name">{{item.coinName}}</span>
        <span class="assets-num">{{item.amount}}</span>
        <span class="assets-link">{{item.address}}</span>
        <span class="assets-copy" @click="handleCopy(item.address)">复制</span>
        <span class="assets-develop">提币(开发中)</span>
      </li>
    </ul>
  </div>
</template>

<script>
  import Api from '@/axios/api/api'

  export default {
    name: 'assets',
    data() {
      return {
        accountList: []
      }
    },
    methods: {
      gitAccountList() {
        Api.getAccount().then(res => {
          let result = res.data
          if (result.code === 0) {
            this.accountList = result.data
          } else {
            this.$message.error(result.message)
          }
        })
      },
      handleCopy(option) { // 复制详情
        let vm = this
        this.$copyText(option).then(function (e) {
          if (e.text) {
            vm.$message.success('复制成功')
            console.log(e.text)
          }
        }, function (e) {
          alert('Can not copy')
          console.log(e)
        })
      }
    },
    mounted() {
      this.gitAccountList()
    }
  }
</script>

<style lang="less" scoped>
  #assets {
    width: 100%;
    height: auto;
    display: block;
    overflow: hidden;
    .assets-header {
      width: 100%;
      height: 126px;
      position: relative;
      display: block;
      overflow: hidden;
      > img {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        margin: auto auto;
        max-width: 100%;
        max-height: 100%;
        display: block;
        overflow: hidden;
      }
    }
    .assets-list {
      width: 100%;
      height: auto;
      display: block;
      overflow: hidden;
      padding: 0 38px;
      padding-bottom: 24px;
      box-sizing: border-box;
      > li {
        width: 100%;
        height: 88px;
        line-height: 88px;
        border-bottom: 1px solid #D8D8D8;
        font-family: PingFangSC-Medium;
        font-size: 16px;
        color: #000000;
        text-align: left;
        > span {
          float: left;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          display: block;
        }
        .assets-name {
          width: 114px;
        }
        .assets-num {
          width: 94px;
        }
        .assets-link {
          width: 420px;
        }
        .assets-copy, .assets-develop {
          height: 40px;
          line-height: 40px;
          margin-top: 24px;
          border-radius: 4px;
          font-family: PingFangSC-Regular;
          text-align: center;
          cursor: pointer;
        }
        .assets-copy {
          width: 80px;
          background: #8638FD;
          font-size: 16px;
          color: #FFFFFF;
          margin-right: 20px;
        }
        .assets-develop {
          width: 114px;
          background: #E2E2E2;
          color: #969696;
        }
      }
      > .active {
        .assets-develop {
          background: #8638FD;
          color: #FFFFFF;
        }
      }
    }
  }
</style>
